package com.example.hand.app.service.impl;

import com.example.hand.app.service.EmployeeService;
import com.example.hand.domain.entity.Employee;
import com.example.hand.infra.mapper.EmployeeMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {


    private final EmployeeMapper employeeMapper;

    public EmployeeServiceImpl(EmployeeMapper employeeMapper) {
        this.employeeMapper = employeeMapper;
    }


    /**
     * 查询所有
     * @param employee
     * @return
     */
    @Override
    public List<Employee> selectEmployeeList(Employee employee) {
        List<Employee> employeeList = employeeMapper.selectEmployeeList(employee);
        return employeeList;

    }

    /**
     * 通过id查询
     * @param employeeId
     * @return
     */
    @Override
    public Employee selectEmployeeById(Long employeeId) {
        Employee employee = employeeMapper.selectEmployeeById(employeeId);
        return employee;
    }

    /**
     * 添加
     * @param employee
     * @return
     */
    @Override
    public Employee insertEmployee(Employee employee) {
        Employee insertEmployee= employeeMapper.insertEmployee(employee);
        return insertEmployee;
    }

    /**
     * 修改
     * @param employee
     * @return
     */
    @Override
    public Employee updateEmployee(Employee employee) {
        Employee updateEmployee = employeeMapper.updateEmployee(employee);
        return updateEmployee;
    }

    /**
     * 删除
     * @param employeeId
     * @return
     */
    @Override
    public Employee deleteEmployee(Long employeeId) {
        Employee deleteEmployee = employeeMapper.deleteEmployee(employeeId);
        return deleteEmployee;
    }

    /**
     * 根据empId查询下属员工
     * @param employeeId
     * @return
     */
    @Override
    public Employee getLeaderByEmployeeId(Employee employeeId) {
        Employee getLeaderByEmployeeId = employeeMapper.getLeaderByEmployeeId(employeeId);
        return getLeaderByEmployeeId;
    }


}
